package yiguan;

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;

public class AuthFilter implements Filter {

	public void init(FilterConfig filterConfig) {

	}

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
				throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest)request;
		HttpServletResponse res = (HttpServletResponse)response;

		String uid = (String) req.getSession().getAttribute("uid");
		if ((uid == null) || (uid.length() == 0))
			res.sendRedirect("login.html");
		else
			chain.doFilter(request, response);
	}

	public void destroy() {

	}
}